/* 
 * Copyright (C) 2007 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.androy.hoola;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

/**
 * A list view example where the data for the list comes from an array of
 * strings.
 */
public class Monthly extends ListActivity {

    private Map<String, String> monthlyTitles = new HashMap<String, String>();

    @Override
    public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	buildMonthlyTitles();

	List<String> list = new ArrayList<String>();
	list.addAll(monthlyTitles.values());
	Collections.sort(list);
	setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list.toArray(new String[0])));
	getListView().setTextFilterEnabled(true);
    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
	Intent intent = new Intent(this, Horoscope.class);
	intent.putExtra("category", monthlyTitles.keySet().toArray()[position]+"");
	startActivity(intent);
    }

    private void buildMonthlyTitles() {
	monthlyTitles.put("monthlyoverview", "Overview");
	monthlyTitles.put("monthlyromantic", "Romantic");
	monthlyTitles.put("monthlyfitness", "Fitness");
	monthlyTitles.put("monthlycareer", "Career");
    }

}
